package base.src;

import game.base.GameThread;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;

public class BatalhaNavalActivity extends Activity {
	/** Called when the activity is first created. */
	private GameThread gameThread;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setKeepScreenOn(this, true);
		loadProperties();
		loadResources();
		gameThread = new GameThread(this);
		gameThread.changeScreen(new MenuScreen(this));
		setContentView(gameThread);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
	}
	
	private void loadResources() {
		Images.LoadAll(getAssets());
	}
	
	public void setKeepScreenOn(Activity activity, boolean keepScreenOn) {
		if (keepScreenOn) {
			activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
		} else {
			activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
		}
	}
	
	private void loadProperties() {
		Display display = getWindowManager().getDefaultDisplay();
		int width = display.getWidth();
		int height = display.getHeight();
		Properties.setScreenSize(width, height);
	}
	
	@Override
	protected void onPause() {
		super.onPause();
	}
	
	@Override
	protected void onStop() {
		super.onStop();
	}
	
	
	public GameThread getGame() {
		return gameThread;
	}
}